package com.example.aics.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.example.aics.store.MongoChatMemotyStore;

import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import jakarta.annotation.Resource;

/**
 * 基于LangChain4j的独立Chat Assistant配置类
 * 主要用于配置ChatMemoryProvider，用于管理每个Chat会话的内存
 */
@Configuration
public class SeparateChatAssistantConfig {

    @Resource
    private MongoChatMemotyStore mongoChatMemotyStore;

    @Bean
    public ChatMemoryProvider chatMemoryProvider(){
        return memoryId -> MessageWindowChatMemory
                     .builder()
                     .id(String.valueOf(memoryId))
                     .maxMessages(10)
                     // .chatMemoryStore(new InMemoryChatMemoryStore())
                     .chatMemoryStore(mongoChatMemotyStore)
                     .build();
    }

}
